home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / vlapak1.zip / MODINFO.ZIP / DACPLAY.ASM next >
Assembly Source File  |  1993-04-16  |  3KB  |  161 lines

  1.       DOSSEG
  2.       .MODEL SMALL
  3.       .STACK 200h
  4.       .CODE
  5.       .386
  6.       ASSUME CS:@CODE, DS:@CODE
  7.       Ideal
  8.  
  9. ────────────────────────────────────────────────────────
  10.  
  11. OldInt  dd  ?
  12.  
  13. LptAddress dw 3bch
  14.  
  15. SampleSeg dw  ?
  16. SampleOff dw  0
  17.  
  18. FileName  db  "jamhot.sam",0   ;you need to put your filename here...
  19. SamLength dw  ?
  20.  
  21. ────────────────────────────────────────────────────────
  22.  
  23. PROC SetUpInterrupt NEAR
  24.     pusha
  25.     push    ds
  26.  
  27.     mov   ax,0
  28.     mov   ds,ax
  29.     mov   bx,8*4                  ;interrupt 8
  30.     mov   ax,[ds:bx]
  31.     mov   [Word LOW  cs:OldInt],ax
  32.     mov   ax,[ds:bx+2]
  33.     mov   [Word HIGH cs:OldInt],ax
  34.  
  35.     cli
  36.     mov   [Word ds:bx],offset TimerInt
  37.     mov   [ds:bx+2],cs
  38.  
  39.     mov   al,36h
  40.     out   43h,al                  ; timer program
  41.  
  42.     mov   ax,1193180/8000         ; # of ticks between interrupts
  43.                                   ; Clock Freq / HZ
  44.     out   40h,al
  45.     mov   al,ah
  46.     out   40h,al
  47.     sti
  48.  
  49.     pop     ds
  50.     popa
  51.     ret
  52. ENDP SetUpInterrupt
  53.   
  54. PROC RemoveInterrupt NEAR
  55.     pusha
  56.     push    ds
  57.     
  58.     cli
  59.     mov ax,0
  60.     mov ds,ax
  61.     mov bx,8*4
  62.     mov ax,[Word cs:OldInt]
  63.     mov [ds:bx],ax
  64.     mov ax,[Word cs:OldInt+2]
  65.     mov [ds:bx+2],ax
  66.     mov al,36h
  67.     out 43h,al
  68.     xor al,al
  69.     out 40h,al
  70.     out 40h,al
  71.     sti
  72.  
  73.     pop     ds
  74.     popa
  75.     ret
  76. ENDP  RemoveInterrupt
  77.  
  78. PROC TimerInt FAR
  79.     pusha
  80.     push    fs
  81.     
  82.     mov     fs,[cs:SampleSeg]
  83.     mov     di,[cs:SampleOff]
  84.     
  85.     mov     al,[fs:di]
  86.     add     al,128            ;change SAM data (-128 to 127) to SB data 0-255
  87.     mov     dx,[cs:LptAddress]
  88.     out     dx,al
  89.     
  90.     inc     [cs:SampleOff]
  91.     mov     ax,[CS:SamLength]
  92.     cmp     [cs:SampleOff],ax
  93.     jb      @@NotOver
  94.     mov     [cs:SampleOff],0
  95.  
  96. @@NotOver:
  97.     mov     al,20h      ;acknowledge hardware interrupt
  98.     out     20h,al
  99.  
  100.     pop     fs
  101.     popa
  102.     iret
  103. ENDP TimerInt
  104.  
  105.   ; returns -1 if load not successful
  106. PROC  LoadSample NEAR
  107.     pusha
  108.  
  109.     mov     ax,cs
  110.     mov     ds,ax
  111.     mov     dx,offset FileName
  112.     mov     ax,3D00h        ;open the file
  113.     int     21h
  114.     jc      @@Error
  115.  
  116.     mov     bx,ax
  117.     xor     dx,dx             ;load at offset 0
  118.     mov     cx,0ffffh         ;read in a whole segments worth
  119.     mov     ds,[cs:SampleSeg]
  120.     mov     ax,3F00h          ; Load in the sample
  121.     int     21h
  122.  
  123.     mov     [cs:SamLength],ax
  124.  
  125.     mov     ax,3E00h          ;close the file
  126.     int     21h
  127.     
  128.     popa
  129.     xor     ax,ax
  130.     ret
  131.  
  132. @@Error:
  133.     popa
  134.     mov     ax,-1
  135.     ret
  136. ENDP  LoadSample
  137.  
  138. ────────────────────────────────────────────────────────────────────────────
  139.  
  140. START:
  141.     mov   bx,ss
  142.     add   bx,20h            ;put sample right after stack
  143.     mov   [cs:SampleSeg],bx
  144.  
  145.     call  LoadSample
  146.     or    al,al
  147.     jne   ByeBye
  148.  
  149.     call  SetUpInterrupt    ;starts going after this line
  150.  
  151.     mov   ah,0
  152.     int   16h               ;wait for a keypress
  153.     
  154.     call  RemoveInterrupt
  155.  
  156. ByeBye:    
  157.     mov   ax,4c00h
  158.     int   21h
  159.  
  160. END START
  161.